// 测试
(function(){
	
function test_eigens(rows){
	mat = math.zeros(rows, rows)
	for(let i = 0; i < rows; i++){
		for(let j = i; j < rows; j++){
			let value = math.randomInt(3)
			mat.set([i, j], value)
			mat.set([j, i], value)
		}
	}

	let res = math.eigens(mat)
	let value = res[0], vec = math.transpose(res[1])
	let diag = math.zeros(rows, rows)
	for(let i = 0; i < rows; i++){
			diag.set([i, i], value[i])
	}
	console.assert(math.max(math.abs(
		math.subtract(math.multiply(vec, diag), math.multiply(mat, vec))
		)) < 1e-8
	)
}


console.log('测试实对称矩阵的特征值计算')
for(let i = 0; i < 100; i++){
	test_eigens(3)
}
console.log('测试结束')
})()
